package com.aizuda.boot.modules.business.mobile.controller;

import com.aizuda.boot.modules.business.contract.dto.SingleResponse;
import com.aizuda.boot.modules.business.contract.util.AuthUtil;
import com.aizuda.boot.modules.business.mobile.service.MobileService;
import com.aizuda.boot.modules.business.mobile.entity.vo.MobileStatisticsVO;
import com.aizuda.boot.modules.business.mobile.entity.vo.MyContractCountVO;
import com.aizuda.boot.modules.business.mobile.entity.vo.MyReminderCountVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

/**
 * Mobile端统计接口控制器
 */
@Tag(name = "Mobile端统计接口")
@Slf4j
@RestController
@RequestMapping("/mobile")
@RequiredArgsConstructor
public class MobileController {

    private final MobileService mobileService;

    /**
     * 获取Mobile端统计数据
     * 包括：我的待办总数、抄送我的总数、待我协商总数
     * @return 统计数据
     */
    @Operation(summary = "获取Mobile端统计数据")
    @GetMapping("/taskCenter-count")
    public SingleResponse<MobileStatisticsVO> getStatistics() {
        Long userId = AuthUtil.getCurrentUser().getId();
        log.info("获取Mobile端统计数据，用户ID: {}", userId);
        
        MobileStatisticsVO statistics = mobileService.getStatistics(userId);
        return SingleResponse.of(statistics);
    }

    @GetMapping("/my-contract-count")
    @Operation(summary = "获取我的合同统计数据")
    public SingleResponse<MyContractCountVO> getMyContractCount() {
        Long userId = AuthUtil.getCurrentUser().getId();
        MyContractCountVO contractCount = mobileService.getMyContractCount(userId);
        return SingleResponse.of(contractCount);
    }

    @GetMapping("/my-reminder-count")
    @Operation(summary = "获取我的提醒统计数据")
    public SingleResponse<MyReminderCountVO> getMyReminderCount() {
        Long userId = AuthUtil.getCurrentUser().getId();
        MyReminderCountVO reminderCount = mobileService.getMyReminderCount(userId);
        return SingleResponse.of(reminderCount);
    }
}